// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#pragma once

#include <pollux/common/file/file.h>

namespace kumo::pollux::config {
class ConfigBase;
}

namespace kumo::pollux::filesystems {
class AbfsReadFile final : public ReadFile {
 public:
  explicit AbfsReadFile(
      std::string_view path,
      const config::ConfigBase& config);

  void initialize(const FileOptions& options);

  std::string_view pread(
      uint64_t offset,
      uint64_t length,
      void* buf,
      File::IoStats* stats = nullptr) const final;

  std::string pread(
      uint64_t offset,
      uint64_t length,
      File::IoStats* stats = nullptr) const final;

  uint64_t preadv(
      uint64_t offset,
      const std::vector<melon::Range<char*>>& buffers,
      File::IoStats* stats = nullptr) const final;

  uint64_t preadv(
      melon::Range<const common::Region*> regions,
      melon::Range<melon::IOBuf*> iobufs,
      File::IoStats* stats = nullptr) const final;

  uint64_t size() const final;

  uint64_t memoryUsage() const final;

  bool shouldCoalesce() const final;

  std::string getName() const final;

  uint64_t getNaturalReadSize() const final;

 protected:
  class Impl;
  std::shared_ptr<Impl> impl_;
};
} // namespace kumo::pollux::filesystems
